package com.xpgk.mvc.ddc.statistic.cphmStastic;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.ddc.entity.Vehicle;

public class CPHMStasticController extends BaseController {
	public void index() {
		String deptid = getCUserOrganIds();
		BigDecimal count =null;
		List<Record> list = new ArrayList<Record>();
		if (deptid.equals("f73bfba518ff4048afbdc006e3eda906")) {
			Record r = Db.findFirst("select count(*)  count from ddc_vehicle");
			if (r != null) {
				count = r.get("count");
			}
			list = Db.find("SELECT  b.name  ,a.count   FROM(SELECT  COUNT(ids) count , orgid  FROM  ddc_vehicle  v    GROUP BY  v.orgid  ) a ,sys_department   b WHERE  a.orgid = b.ids");
		} else {
			Record r = Db.findFirst("select count(*)  count from ddc_vehicle  where orgid = ?" ,deptid);
			if (r != null) {
				count = r.get("count");
			}
		}
		setAttr("count", count);
		setAttr("list", list);
		render("/ddc_stastic/cphmStastic/cphmStastic.html");
	}

	/**
	 * 号牌列表
	 */
	public void view() {
		String json = paging(splitPage, Vehicle.sqlId_splitPageSelect, Vehicle.sqlId_splitPageFrom);
		renderJson(json);
	}

}
